package com.pristine.dao;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.pristine.domain.CountryMasterEntity;
import com.pristine.domain.StateMasterEntity;
import com.pristine.util.GenericDaoImpl;

@Repository("countryMasterDao")
public class CountryMasterDaoImpl extends GenericDaoImpl<CountryMasterEntity, Integer>implements
		ICountryMasterDao {
	
	
	
	@Autowired
	private SessionFactory sessionFactory;

	@SuppressWarnings("unchecked")
	@Override
	public List<StateMasterEntity> getStatesByCountryId(Integer countryId) {

		Session session = sessionFactory.getCurrentSession();
		String queryString = "from com.pristine.domain.StateMasterEntity s where s.countryMaster.id="
				+ countryId;

		List<StateMasterEntity> list = session.createQuery(queryString).list();
		return list;
	}

}
